package net.mingsoft.report_data.biz.impl.report_gen;

import com.alibaba.fastjson.JSON;
import com.baomidou.dynamic.datasource.annotation.DS;
import net.mingsoft.report_data.biz.ZkDataPublicOpinionBiz;
import net.mingsoft.report_data.dao.ZkDataYqDao;
import net.mingsoft.report_data.entity.GidEntity;
import net.mingsoft.report_data.entity.HotEntity;
import net.mingsoft.report_data.entity.NewIncreaseEntity;
import net.mingsoft.report_data.entity.vo.DateWithCountDto;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author gengfa
 * @date 22/05/25
 */
@Service
@DS("yq")
public class ZkDataPublicOpinionBizImpl implements ZkDataPublicOpinionBiz {

    @Resource
    ZkDataYqDao dataYqDao;

    @Override
    public Map<String, Object> getHotEvents(Map<String, Object> map) {
        final String beginDate = (String) map.get("beginDate");
        final String endDate = (String) map.get("endDate");
        List<HotEntity> hotEntities = dataYqDao.selectInIslandHotEvents(beginDate, endDate);
        map.put("hotEventList", JSON.toJSONString(hotEntities));
        return map;
    }

    @Override
    public Map<String, Object> getPublicOpinionDevelopment(Map<String, Object> map) {
        final String beginDate = (String) map.get("beginDate");
        final String endDate = (String) map.get("endDate");
        List<NewIncreaseEntity> newIncreaseEntities = dataYqDao.selectInIslandPublicOpinionDevelopment(beginDate, endDate);
        map.put("newIncreaseEntities", JSON.toJSONString(newIncreaseEntities));
        return map;
    }

    @Override
    public Map<String, Object> getMediaReportTrending(Map<String, Object> map) {
        final String beginDate = (String) map.get("beginDate");
        final String endDate = (String) map.get("endDate");
        List<DateWithCountDto> reportTrendingList = dataYqDao.countRecentInIslandPublicOpinions(beginDate, endDate);
        map.put("reportTrendingList", JSON.toJSONString(reportTrendingList));
        return map;
    }

    @Override
    public Map<String, Object> getPopMediaWithNegativeInfo(Map<String, Object> map) {
        final String beginDate = (String) map.get("beginDate");
        final String endDate = (String) map.get("endDate");
        List<GidEntity> gidEntities = dataYqDao.selectPopMediaWithNegativeInfo(beginDate, endDate);
        int gidCount = dataYqDao.countPopMediaWithNegativeInfo(beginDate, endDate);
        map.put("gidEntities", JSON.toJSONString(gidEntities));
        map.put("gidCount", gidCount);
        return map;

    }

    @Override
    public Map<String, Object> getInIslandAntiSmugglerReportCount(Map<String, Object> map) {
        final String beginDate = (String) map.get("beginDate");
        final String endDate = (String) map.get("endDate");
        List<DateWithCountDto> reportCountList = dataYqDao.countInIslandAntiSmuggleReport(beginDate, endDate);
        map.put("reportCountList", JSON.toJSONString(reportCountList));
        return map;
    }
}
